<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue-2.4.0.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 对象 -->
      <div :style="style">colorcolorcolor</div>
      <!-- 数组 -->
      <div :style="[style01,style02]">colorcolorcolorcolorcolorcolor</div>
      <!-- 函数返回值 -->
      <div :style="getColor(2)">3、函数返回值</div>
      <button @click="change">改变颜色</button>
    </div>
  </body>
  <script>
    let vm = new Vue({
      el: "#app",
      data: {
        style01: {
          color: "red",
          fontSize: "40px",
        },
        style02: {
          backgroundColor: "blue",
        },
      },
      methods: {
        change() {
          this.style01.color = "green";
        },
        getColor(n) {
          if (n == 1) {
            return {
              color: "red",
            };
          } else if (n == 2) {
            return {
              color: "blue",
            };
          }
        },
      },
    });
  </script>
</html>
